home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 3 / CD ACTUAL 3.iso / linux / sonido / mod-0.000 / mod-0 / mod / mklist.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-04  |  1.2 KB  |  56 lines

  1. /*
  2.  *  makelist.c - Creates a shell-script to play a sequence of modules.
  3.  *
  4.  *  (C) 1994 Mikael Nordqvist (d91mn@efd.lth.se, mech@df.lth.se)
  5.  */
  6.  
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9.  
  10. #include "mod.h"
  11.  
  12. extern struct options default_opt;
  13. extern char workdir[PATH_MAX+1];
  14. extern short *songs, *song_sequence;
  15. extern int nr_songs;
  16. extern char **av;
  17. extern int ac;
  18.  
  19. void mklist(int argc, char *argv[])
  20. {
  21.     int i, j;
  22.  
  23.     /* These must allocated before check_options(0) is called */
  24.     songs=(short *)malloc(argc*sizeof(short));
  25.     song_sequence=(short *)malloc(argc*sizeof(short));
  26.  
  27.     av=argv;
  28.     ac=argc;
  29.     
  30.     /* Make sure the options are valid */
  31.     nr_songs=0;
  32.     check_options(0);
  33.     if(nr_songs < 1)
  34.     error("No songs supplied.\n");
  35.     
  36.     /* Header */
  37.     printf("#!/bin/sh\nexec mod");
  38.  
  39.     /* Global options */
  40.     for(i=0; i < songs[0]-1; ++i)
  41.     printf(" %s", argv[i+1]);
  42.     printf(" -D%s $* \\\n", escape_name(workdir, 0));
  43.     
  44.     /* Files */
  45.     for(i=0; i < nr_songs; ++i) {
  46.     printf(escape_name(argv[songs[i]], 0));
  47.     for(j=songs[i]+1; j < songs[i+1]; ++j)
  48.         printf(" %s", argv[j]);
  49.     if(i != nr_songs-1)
  50.         printf(" \\\n");
  51.     else
  52.         printf("\n");
  53.     }
  54.     exit(0);
  55. }
  56.